CREATE OR REPLACE PACKAGE BODY Absence_Action_API IS

-----------------------------------------------------------------------------
-------------------- PRIVATE DECLARATIONS -----------------------------------
-----------------------------------------------------------------------------

TYPE Indicator_Rec IS RECORD
  (company_id                     BOOLEAN := FALSE,
   action_id                      BOOLEAN := FALSE,
   action_description             BOOLEAN := FALSE,
   remarks                        BOOLEAN := FALSE);


-----------------------------------------------------------------------------
-------------------- IMPLEMENTATION METHOD DECLARATIONS ---------------------
-----------------------------------------------------------------------------

PROCEDURE Raise_Too_Many_Rows___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2,
   methodname_ IN VARCHAR2 );

PROCEDURE Raise_Record_Not_Exist___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 );

PROCEDURE Raise_Record_Exist___ (
   rec_ absence_action_tab%ROWTYPE );

PROCEDURE Raise_Item_Format___ (
   name_ IN VARCHAR2,
   value_ IN VARCHAR2 );

PROCEDURE Raise_Record_Modified___ (
   rec_ absence_action_tab%ROWTYPE );

PROCEDURE Raise_Record_Locked___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 );

PROCEDURE Raise_Record_Removed___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 );

FUNCTION Lock_By_Id___ (
   objid_      IN VARCHAR2,
   objversion_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE;

FUNCTION Lock_By_Keys___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE;

FUNCTION Lock_By_Keys_Nowait___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE;

FUNCTION Get_Object_By_Id___ (
   objid_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE;

FUNCTION Get_Object_By_Keys___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE;

FUNCTION Check_Exist___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN BOOLEAN;

PROCEDURE Get_Version_By_Id___ (
   objid_      IN     VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2 );

PROCEDURE Get_Id_Version_By_Keys___ (
   objid_      IN OUT NOCOPY VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2,
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 );

PROCEDURE Unpack___ (
   newrec_   IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_   IN OUT NOCOPY Indicator_Rec,
   attr_     IN OUT NOCOPY VARCHAR2 );

FUNCTION Pack___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2;

FUNCTION Pack___ (
   rec_ IN absence_action_tab%ROWTYPE,
   indrec_ IN Indicator_Rec ) RETURN VARCHAR2;

FUNCTION Pack_Table___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2;

PROCEDURE Reset_Indicator_Rec___ (
   indrec_ IN OUT NOCOPY Indicator_Rec );

FUNCTION Get_Indicator_Rec___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec;

FUNCTION Get_Indicator_Rec___ (
   oldrec_ IN absence_action_tab%ROWTYPE,
   newrec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec;

PROCEDURE Check_Common___ (
   oldrec_ IN     absence_action_tab%ROWTYPE,
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 );

PROCEDURE Prepare_Insert___ (
   attr_ IN OUT NOCOPY VARCHAR2 );

PROCEDURE Check_Insert___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 );

PROCEDURE Insert___ (
   objid_      OUT    VARCHAR2,
   objversion_ OUT    VARCHAR2,
   newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
   attr_       IN OUT NOCOPY VARCHAR2 );

PROCEDURE Prepare_New___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE );

PROCEDURE New___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE );

PROCEDURE Check_Update___ (
   oldrec_ IN     absence_action_tab%ROWTYPE,
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 );

PROCEDURE Update___ (
   objid_      IN     VARCHAR2,
   oldrec_     IN     absence_action_tab%ROWTYPE,
   newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
   attr_       IN OUT NOCOPY VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2,
   by_keys_    IN     BOOLEAN DEFAULT FALSE );

PROCEDURE Modify___ (
   newrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
   lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE );

PROCEDURE Check_Delete___ (
   remrec_ IN ABSENCE_ACTION_TAB%ROWTYPE );

PROCEDURE Delete___ (
   objid_  IN VARCHAR2,
   remrec_ IN absence_action_tab%ROWTYPE );

PROCEDURE Delete___ (
   remrec_ IN absence_action_tab%ROWTYPE );

PROCEDURE Remove___ (
   remrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
   lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE );

PROCEDURE Export___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec );

PROCEDURE Export_Assign___ (
   pub_rec_     IN OUT NOCOPY Enterp_Comp_Connect_V170_API.Tem_Public_Rec,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   exprec_      IN     absence_action_tab%ROWTYPE );

PROCEDURE Import___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec );

PROCEDURE Import_Assign___ (
   newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   pub_rec_     IN     Create_Company_Template_Pub%ROWTYPE );

PROCEDURE Copy___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec );

PROCEDURE Copy_Assign___ (
   newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   oldrec_      IN     absence_action_tab%ROWTYPE );

FUNCTION Exist_Any___ (
   company_ IN VARCHAR2 ) RETURN BOOLEAN;

FUNCTION Check_If_Do_Create_Company___ (
   crecomp_rec_ IN ENTERP_COMP_CONNECT_V170_API.Crecomp_Lu_Public_Rec ) RETURN BOOLEAN;

PROCEDURE Check_Action_Usage___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2);

-----------------------------------------------------------------------------
-------------------- BASE METHODS -------------------------------------------
-----------------------------------------------------------------------------

--@IgnoreMissingSysinit
FUNCTION Get_Key_By_Rowkey (
   rowkey_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      rowkey_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
   IS
      rec_ absence_action_tab%ROWTYPE;
   BEGIN
      SELECT company_id, action_id
         INTO  rec_.company_id, rec_.action_id
         FROM  absence_action_tab
         WHERE rowkey = rowkey_;
      RETURN rec_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN rec_;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(rec_.company_id, rec_.action_id, 'Get_Key_By_Rowkey');
   END Base;

BEGIN
   RETURN Base(rowkey_);
END Get_Key_By_Rowkey;


--@IgnoreMissingSysinit
PROCEDURE Exist (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 )
   IS
   BEGIN
      IF (NOT Check_Exist___(company_id_, action_id_)) THEN
         Raise_Record_Not_Exist___(company_id_, action_id_);
      END IF;
   END Base;

BEGIN
   Base(company_id_, action_id_);
END Exist;


--@IgnoreMissingSysinit
FUNCTION Exists (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN BOOLEAN
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN BOOLEAN
   IS
   BEGIN
      RETURN Check_Exist___(company_id_, action_id_);
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Exists;


--@IgnoreMissingSysinit
FUNCTION Get_Action_Description (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN VARCHAR2
   IS
      temp_ absence_action_tab.action_description%TYPE;
   BEGIN
      IF (company_id_ IS NULL OR action_id_ IS NULL) THEN
         RETURN NULL;
      END IF;
      SELECT substr(nvl(Employee_Translation_API.Get_Basic_Data_Translation('WRKSCH', 'AbsenceAction',
                 company_id||'^'||action_id), action_description), 1, 40)
         INTO  temp_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN temp_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get_Action_Description');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Get_Action_Description;


--@IgnoreMissingSysinit
FUNCTION Get_Remarks (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN VARCHAR2
   IS
      temp_ absence_action_tab.remarks%TYPE;
   BEGIN
      IF (company_id_ IS NULL OR action_id_ IS NULL) THEN
         RETURN NULL;
      END IF;
      SELECT remarks
         INTO  temp_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN temp_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get_Remarks');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Get_Remarks;


--@IgnoreMissingSysinit
FUNCTION Get (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN Public_Rec
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN Public_Rec
   IS
      temp_ Public_Rec;
   BEGIN
      IF (company_id_ IS NULL OR action_id_ IS NULL) THEN
         RETURN NULL;
      END IF;
      SELECT company_id, action_id,
             rowid, rowversion, rowkey,
              substr(nvl(Employee_Translation_API.Get_Basic_Data_Translation('WRKSCH', 'AbsenceAction',
                 company_id||'^'||action_id), action_description), 1, 40), 
             remarks
         INTO  temp_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN temp_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Get;


--@IgnoreMissingSysinit
FUNCTION Get_Objkey (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN VARCHAR2
   IS
      rowkey_ absence_action_tab.rowkey%TYPE;
   BEGIN
      IF (company_id_ IS NULL OR action_id_ IS NULL) THEN
         RETURN NULL;
      END IF;
      SELECT rowkey
         INTO  rowkey_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN rowkey_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get_Objkey');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Get_Objkey;


--@IgnoreMissingSysinit
PROCEDURE Lock__ (
   info_       OUT VARCHAR2,
   objid_      IN  VARCHAR2,
   objversion_ IN  VARCHAR2 )
IS
   
   PROCEDURE Base (
      info_       OUT VARCHAR2,
      objid_      IN  VARCHAR2,
      objversion_ IN  VARCHAR2 )
   IS
      dummy_ absence_action_tab%ROWTYPE;
   BEGIN
      dummy_ := Lock_By_Id___(objid_, objversion_);
      info_ := Client_SYS.Get_All_Info;
   END Base;

BEGIN
   Base(info_, objid_, objversion_);
END Lock__;


PROCEDURE New__ (
   info_       OUT    VARCHAR2,
   objid_      OUT    VARCHAR2,
   objversion_ OUT    VARCHAR2,
   attr_       IN OUT NOCOPY VARCHAR2,
   action_     IN     VARCHAR2 )
IS
   
   PROCEDURE Base (
      info_       OUT    VARCHAR2,
      objid_      OUT    VARCHAR2,
      objversion_ OUT    VARCHAR2,
      attr_       IN OUT NOCOPY VARCHAR2,
      action_     IN     VARCHAR2 )
   IS
      newrec_   absence_action_tab%ROWTYPE;
      indrec_   Indicator_Rec;
   BEGIN
      IF (action_ = 'PREPARE') THEN
         Prepare_Insert___(attr_);
      ELSIF (action_ = 'CHECK') THEN
         Unpack___(newrec_, indrec_, attr_);
         Check_Insert___(newrec_, indrec_, attr_);
      ELSIF (action_ = 'DO') THEN
         Unpack___(newrec_, indrec_, attr_);
         Check_Insert___(newrec_, indrec_, attr_);
         Insert___(objid_, objversion_, newrec_, attr_);
      END IF;
      info_ := Client_SYS.Get_All_Info;
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'New__');
   Base(info_, objid_, objversion_, attr_, action_);
END New__;


PROCEDURE Modify__ (
   info_       OUT    VARCHAR2,
   objid_      IN     VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2,
   attr_       IN OUT NOCOPY VARCHAR2,
   action_     IN     VARCHAR2 )
IS
   
   PROCEDURE Base (
      info_       OUT    VARCHAR2,
      objid_      IN     VARCHAR2,
      objversion_ IN OUT NOCOPY VARCHAR2,
      attr_       IN OUT NOCOPY VARCHAR2,
      action_     IN     VARCHAR2 )
   IS
      oldrec_   absence_action_tab%ROWTYPE;
      newrec_   absence_action_tab%ROWTYPE;
      indrec_   Indicator_Rec;
   BEGIN
      IF (action_ = 'CHECK') THEN
         oldrec_ := Get_Object_By_Id___(objid_);
         newrec_ := oldrec_;
         Unpack___(newrec_, indrec_, attr_);
         Check_Update___(oldrec_, newrec_, indrec_, attr_);
      ELSIF (action_ = 'DO') THEN
         oldrec_ := Lock_By_Id___(objid_, objversion_);
         newrec_ := oldrec_;
         Unpack___(newrec_, indrec_, attr_);
         Check_Update___(oldrec_, newrec_, indrec_, attr_);
         Update___(objid_, oldrec_, newrec_, attr_, objversion_);
      END IF;
      info_ := Client_SYS.Get_All_Info;
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'Modify__');
   Base(info_, objid_, objversion_, attr_, action_);
END Modify__;


PROCEDURE Remove__ (
   info_       OUT VARCHAR2,
   objid_      IN  VARCHAR2,
   objversion_ IN  VARCHAR2,
   action_     IN  VARCHAR2 )
IS
   
   PROCEDURE Base (
      info_       OUT VARCHAR2,
      objid_      IN  VARCHAR2,
      objversion_ IN  VARCHAR2,
      action_     IN  VARCHAR2 )
   IS
      remrec_ absence_action_tab%ROWTYPE;
   BEGIN
      IF (action_ = 'CHECK') THEN
         remrec_ := Get_Object_By_Id___(objid_);
         Check_Delete___(remrec_);
      ELSIF (action_ = 'DO') THEN
         remrec_ := Lock_By_Id___(objid_, objversion_);
         Check_Delete___(remrec_);
         Delete___(objid_, remrec_);
      END IF;
      info_ := Client_SYS.Get_All_Info;
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'Remove__');
   Base(info_, objid_, objversion_, action_);
END Remove__;


PROCEDURE Raise_Too_Many_Rows___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2,
   methodname_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2,
      methodname_ IN VARCHAR2 )
   IS
   BEGIN
      Error_SYS.Too_Many_Rows(Absence_Action_API.lu_name_, NULL, methodname_);
   END Base;

BEGIN
   Base(company_id_, action_id_, methodname_);
END Raise_Too_Many_Rows___;


PROCEDURE Raise_Record_Not_Exist___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 )
   IS
   BEGIN
      Error_SYS.Record_Not_Exist(Absence_Action_API.lu_name_);
   END Base;

BEGIN
   Base(company_id_, action_id_);
END Raise_Record_Not_Exist___;


PROCEDURE Raise_Record_Exist___ (
   rec_ absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      rec_ absence_action_tab%ROWTYPE )
   IS
   BEGIN
      Error_SYS.Record_Exist(Absence_Action_API.lu_name_);
   END Base;

BEGIN
   Base(rec_);
END Raise_Record_Exist___;


PROCEDURE Raise_Item_Format___ (
   name_ IN VARCHAR2,
   value_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      name_ IN VARCHAR2,
      value_ IN VARCHAR2 )
   IS
   BEGIN
      Error_SYS.Item_Format(Absence_Action_API.lu_name_, name_, value_);
   END Base;

BEGIN
   Base(name_, value_);
END Raise_Item_Format___;


PROCEDURE Raise_Record_Modified___ (
   rec_ absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      rec_ absence_action_tab%ROWTYPE )
   IS
   BEGIN
      Error_SYS.Record_Modified(Absence_Action_API.lu_name_);
   END Base;

BEGIN
   Base(rec_);
END Raise_Record_Modified___;


PROCEDURE Raise_Record_Locked___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 )
   IS
   BEGIN
      Error_SYS.Record_Locked(Absence_Action_API.lu_name_);
   END Base;

BEGIN
   Base(company_id_, action_id_);
END Raise_Record_Locked___;


PROCEDURE Raise_Record_Removed___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 )
   IS
   BEGIN
      Error_SYS.Record_Removed(Absence_Action_API.lu_name_);
   END Base;

BEGIN
   Base(company_id_, action_id_);
END Raise_Record_Removed___;


FUNCTION Lock_By_Id___ (
   objid_      IN VARCHAR2,
   objversion_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      objid_      IN VARCHAR2,
      objversion_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
   IS
      row_locked  EXCEPTION;
      PRAGMA      EXCEPTION_INIT(row_locked, -0054);
      rec_        absence_action_tab%ROWTYPE;
      dummy_      NUMBER;
   BEGIN
      SELECT *
         INTO  rec_
         FROM  absence_action_tab
         WHERE rowid = objid_
         AND    to_char(rowversion,'YYYYMMDDHH24MISS') = objversion_
         FOR UPDATE NOWAIT;
      RETURN rec_;
   EXCEPTION
      WHEN row_locked THEN
         Error_SYS.Record_Locked(lu_name_);
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(NULL, NULL, 'Lock_By_Id___');
      WHEN no_data_found THEN
         BEGIN
            SELECT 1
               INTO  dummy_
               FROM  absence_action_tab
               WHERE rowid = objid_;
            Raise_Record_Modified___(rec_);
         EXCEPTION
            WHEN no_data_found THEN
               Error_SYS.Record_Removed(lu_name_);
            WHEN too_many_rows THEN
               Raise_Too_Many_Rows___(NULL, NULL, 'Lock_By_Id___');
         END;
   END Base;

BEGIN
   RETURN Base(objid_, objversion_);
END Lock_By_Id___;


FUNCTION Lock_By_Keys___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE
   IS
      row_locked  EXCEPTION;
      PRAGMA      EXCEPTION_INIT(row_locked, -0054);
      rec_        absence_action_tab%ROWTYPE;
   BEGIN
      BEGIN
         SELECT *
            INTO  rec_
            FROM  absence_action_tab
            WHERE company_id = company_id_
            AND   action_id = action_id_
            FOR UPDATE;
         RETURN rec_;
      EXCEPTION
         WHEN no_data_found THEN
            Raise_Record_Removed___(company_id_, action_id_);
         WHEN too_many_rows THEN
            Raise_Too_Many_Rows___(company_id_, action_id_, 'Lock_By_Keys___');
      END;
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Lock_By_Keys___;


FUNCTION Lock_By_Keys_Nowait___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2) RETURN absence_action_tab%ROWTYPE
   IS
      row_locked  EXCEPTION;
      PRAGMA      EXCEPTION_INIT(row_locked, -0054);
      rec_        absence_action_tab%ROWTYPE;
      dummy_      NUMBER;
   BEGIN
      BEGIN
         SELECT *
            INTO  rec_
            FROM  absence_action_tab
            WHERE company_id = company_id_
            AND   action_id = action_id_
            FOR UPDATE NOWAIT;
         RETURN rec_;
      EXCEPTION
         WHEN row_locked THEN
            Error_SYS.Record_Locked(lu_name_);
         WHEN too_many_rows THEN
            Raise_Too_Many_Rows___(company_id_, action_id_, 'Lock_By_Keys___');
         WHEN no_data_found THEN
            BEGIN
               SELECT 1
                  INTO  dummy_
                  FROM  absence_action_tab
                  WHERE company_id = company_id_
                  AND   action_id = action_id_;
               Raise_Record_Modified___(rec_);
            EXCEPTION
               WHEN no_data_found THEN
                  Raise_Record_Removed___(company_id_, action_id_);
               WHEN too_many_rows THEN
                  Raise_Too_Many_Rows___(company_id_, action_id_, 'Lock_By_Keys___');
            END;
      END;
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Lock_By_Keys_Nowait___;


FUNCTION Get_Object_By_Id___ (
   objid_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      objid_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
   IS
      lu_rec_ absence_action_tab%ROWTYPE;
   BEGIN
      SELECT *
         INTO  lu_rec_
         FROM  absence_action_tab
         WHERE rowid = objid_;
      RETURN lu_rec_;
   EXCEPTION
      WHEN no_data_found THEN
         Error_SYS.Record_Removed(lu_name_);
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(NULL, NULL, 'Get_Object_By_Id___');
   END Base;

BEGIN
   RETURN Base(objid_);
END Get_Object_By_Id___;


--@IgnoreMissingSysinit
FUNCTION Get_Object_By_Keys___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN absence_action_tab%ROWTYPE
   IS
      lu_rec_ absence_action_tab%ROWTYPE;
   BEGIN
      SELECT *
         INTO  lu_rec_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN lu_rec_;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN lu_rec_;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get_Object_By_Keys___');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Get_Object_By_Keys___;


--@IgnoreMissingSysinit
FUNCTION Check_Exist___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 ) RETURN BOOLEAN
IS
   
   FUNCTION Base (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 ) RETURN BOOLEAN
   IS
      dummy_ NUMBER;
   BEGIN
      SELECT 1
         INTO  dummy_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
      RETURN TRUE;
   EXCEPTION
      WHEN no_data_found THEN
         RETURN FALSE;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Check_Exist___');
   END Base;

BEGIN
   RETURN Base(company_id_, action_id_);
END Check_Exist___;


PROCEDURE Get_Version_By_Id___ (
   objid_      IN     VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      objid_      IN     VARCHAR2,
      objversion_ IN OUT NOCOPY VARCHAR2 )
   IS
   BEGIN
      SELECT to_char(rowversion,'YYYYMMDDHH24MISS')
         INTO  objversion_
         FROM  absence_action_tab
         WHERE rowid = objid_;
   EXCEPTION
      WHEN no_data_found THEN
         objversion_ := NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(NULL, NULL, 'Get_Version_By_Id___');
   END Base;

BEGIN
   Base(objid_, objversion_);
END Get_Version_By_Id___;


PROCEDURE Get_Id_Version_By_Keys___ (
   objid_      IN OUT NOCOPY VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2,
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      objid_      IN OUT NOCOPY VARCHAR2,
      objversion_ IN OUT NOCOPY VARCHAR2,
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2 )
   IS
   BEGIN
      SELECT rowid, to_char(rowversion,'YYYYMMDDHH24MISS')
         INTO  objid_, objversion_
         FROM  absence_action_tab
         WHERE company_id = company_id_
         AND   action_id = action_id_;
   EXCEPTION
      WHEN no_data_found THEN
         objid_      := NULL;
         objversion_ := NULL;
      WHEN too_many_rows THEN
         Raise_Too_Many_Rows___(company_id_, action_id_, 'Get_Id_Version_By_Keys___');
   END Base;

BEGIN
   Base(objid_, objversion_, company_id_, action_id_);
END Get_Id_Version_By_Keys___;


PROCEDURE Unpack___ (
   newrec_   IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_   IN OUT NOCOPY Indicator_Rec,
   attr_     IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      newrec_   IN OUT NOCOPY absence_action_tab%ROWTYPE,
      indrec_   IN OUT NOCOPY Indicator_Rec,
      attr_     IN OUT NOCOPY VARCHAR2 )
   IS
      ptr_   NUMBER;
      name_  VARCHAR2(30);
      value_ VARCHAR2(32000);
      msg_   VARCHAR2(32000);
   BEGIN
      Reset_Indicator_Rec___(indrec_);
      Client_SYS.Clear_Attr(msg_);
      ptr_ := NULL;
      WHILE (Client_SYS.Get_Next_From_Attr(attr_, ptr_, name_, value_)) LOOP
         CASE name_
         WHEN ('COMPANY_ID') THEN
            newrec_.company_id := value_;
            indrec_.company_id := TRUE;
         WHEN ('ACTION_ID') THEN
            newrec_.action_id := value_;
            indrec_.action_id := TRUE;
         WHEN ('ACTION_DESCRIPTION') THEN
            newrec_.action_description := value_;
            indrec_.action_description := TRUE;
         WHEN ('REMARKS') THEN
            newrec_.remarks := value_;
            indrec_.remarks := TRUE;
         ELSE
            Client_SYS.Add_To_Attr(name_, value_, msg_);
         END CASE;
      END LOOP;
      attr_ := msg_;
   EXCEPTION
      WHEN value_error THEN
         Raise_Item_Format___(name_, value_);
   END Base;

BEGIN
   Base(newrec_, indrec_, attr_);
END Unpack___;


FUNCTION Pack___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2
   IS
      attr_ VARCHAR2(32000);
   BEGIN
      Client_SYS.Clear_Attr(attr_);
      IF (rec_.company_id IS NOT NULL) THEN
         Client_SYS.Add_To_Attr('COMPANY_ID', rec_.company_id, attr_);
      END IF;
      IF (rec_.action_id IS NOT NULL) THEN
         Client_SYS.Add_To_Attr('ACTION_ID', rec_.action_id, attr_);
      END IF;
      IF (rec_.action_description IS NOT NULL) THEN
         Client_SYS.Add_To_Attr('ACTION_DESCRIPTION', rec_.action_description, attr_);
      END IF;
      IF (rec_.remarks IS NOT NULL) THEN
         Client_SYS.Add_To_Attr('REMARKS', rec_.remarks, attr_);
      END IF;
      RETURN attr_;
   END Base;

BEGIN
   RETURN Base(rec_);
END Pack___;


FUNCTION Pack___ (
   rec_ IN absence_action_tab%ROWTYPE,
   indrec_ IN Indicator_Rec ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      rec_ IN absence_action_tab%ROWTYPE,
      indrec_ IN Indicator_Rec ) RETURN VARCHAR2
   IS
      attr_ VARCHAR2(32000);
   BEGIN
      Client_SYS.Clear_Attr(attr_);
      IF (indrec_.company_id) THEN
         Client_SYS.Add_To_Attr('COMPANY_ID', rec_.company_id, attr_);
      END IF;
      IF (indrec_.action_id) THEN
         Client_SYS.Add_To_Attr('ACTION_ID', rec_.action_id, attr_);
      END IF;
      IF (indrec_.action_description) THEN
         Client_SYS.Add_To_Attr('ACTION_DESCRIPTION', rec_.action_description, attr_);
      END IF;
      IF (indrec_.remarks) THEN
         Client_SYS.Add_To_Attr('REMARKS', rec_.remarks, attr_);
      END IF;
      RETURN attr_;
   END Base;

BEGIN
   RETURN Base(rec_, indrec_);
END Pack___;


FUNCTION Pack_Table___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2
IS
   
   FUNCTION Base (
      rec_ IN absence_action_tab%ROWTYPE ) RETURN VARCHAR2
   IS
      attr_ VARCHAR2(32000);
   BEGIN
      Client_SYS.Clear_Attr(attr_);
      Client_SYS.Add_To_Attr('COMPANY_ID', rec_.company_id, attr_);
      Client_SYS.Add_To_Attr('ACTION_ID', rec_.action_id, attr_);
      Client_SYS.Add_To_Attr('ACTION_DESCRIPTION', rec_.action_description, attr_);
      Client_SYS.Add_To_Attr('REMARKS', rec_.remarks, attr_);
      Client_SYS.Add_To_Attr('ROWKEY', rec_.rowkey, attr_);
      RETURN attr_;
   END Base;

BEGIN
   RETURN Base(rec_);
END Pack_Table___;


PROCEDURE Reset_Indicator_Rec___ (
   indrec_ IN OUT NOCOPY Indicator_Rec )
IS
   
   PROCEDURE Base (
      indrec_ IN OUT NOCOPY Indicator_Rec )
   IS
      empty_indrec_ Indicator_Rec;
   BEGIN
      indrec_ := empty_indrec_;
   END Base;

BEGIN
   Base(indrec_);
END Reset_Indicator_Rec___;


FUNCTION Get_Indicator_Rec___ (
   rec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec
IS
   
   FUNCTION Base (
      rec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec
   IS
      indrec_ Indicator_Rec;
   BEGIN
      indrec_.company_id := rec_.company_id IS NOT NULL;
      indrec_.action_id := rec_.action_id IS NOT NULL;
      indrec_.action_description := rec_.action_description IS NOT NULL;
      indrec_.remarks := rec_.remarks IS NOT NULL;
      RETURN indrec_;
   END Base;

BEGIN
   RETURN Base(rec_);
END Get_Indicator_Rec___;


FUNCTION Get_Indicator_Rec___ (
   oldrec_ IN absence_action_tab%ROWTYPE,
   newrec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec
IS
   
   FUNCTION Base (
      oldrec_ IN absence_action_tab%ROWTYPE,
      newrec_ IN absence_action_tab%ROWTYPE ) RETURN Indicator_Rec
   IS
      indrec_ Indicator_Rec;
   BEGIN
      indrec_.company_id := Validate_SYS.Is_Changed(oldrec_.company_id, newrec_.company_id);
      indrec_.action_id := Validate_SYS.Is_Changed(oldrec_.action_id, newrec_.action_id);
      indrec_.action_description := Validate_SYS.Is_Changed(oldrec_.action_description, newrec_.action_description);
      indrec_.remarks := Validate_SYS.Is_Changed(oldrec_.remarks, newrec_.remarks);
      RETURN indrec_;
   END Base;

BEGIN
   RETURN Base(oldrec_, newrec_);
END Get_Indicator_Rec___;


PROCEDURE Check_Common___ (
   oldrec_ IN     absence_action_tab%ROWTYPE,
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      oldrec_ IN     absence_action_tab%ROWTYPE,
      newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
      indrec_ IN OUT NOCOPY Indicator_Rec,
      attr_   IN OUT NOCOPY VARCHAR2 )
   IS
   BEGIN
      IF (newrec_.company_id IS NOT NULL)
      AND (indrec_.company_id)
      AND (Validate_SYS.Is_Changed(oldrec_.company_id, newrec_.company_id)) THEN
         Person_Company_API.Exist(newrec_.company_id);
      END IF;
      Error_SYS.Check_Not_Null(lu_name_, 'COMPANY_ID', newrec_.company_id);
      Error_SYS.Check_Not_Null(lu_name_, 'ACTION_ID', newrec_.action_id);
      Error_SYS.Check_Not_Null(lu_name_, 'ACTION_DESCRIPTION', newrec_.action_description);
   END Base;

BEGIN
   Base(oldrec_, newrec_, indrec_, attr_);
END Check_Common___;


PROCEDURE Prepare_Insert___ (
   attr_ IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      attr_ IN OUT NOCOPY VARCHAR2 )
   IS
   BEGIN
      Client_SYS.Clear_Attr(attr_);
   END Base;

BEGIN
   Base(attr_);
END Prepare_Insert___;


PROCEDURE Check_Insert___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
      indrec_ IN OUT NOCOPY Indicator_Rec,
      attr_   IN OUT NOCOPY VARCHAR2 )
   IS
      oldrec_ absence_action_tab%ROWTYPE;
   BEGIN
      Check_Common___(oldrec_, newrec_, indrec_, attr_);
   END Base;

BEGIN
   Base(newrec_, indrec_, attr_);
END Check_Insert___;


PROCEDURE Insert___ (
   objid_      OUT    VARCHAR2,
   objversion_ OUT    VARCHAR2,
   newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
   attr_       IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      objid_      OUT    VARCHAR2,
      objversion_ OUT    VARCHAR2,
      newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
      attr_       IN OUT NOCOPY VARCHAR2 )
   IS
   BEGIN
      newrec_.rowversion := sysdate;
      newrec_.rowkey := sys_guid();
      Client_SYS.Add_To_Attr('OBJKEY', newrec_.rowkey, attr_);
      INSERT
         INTO absence_action_tab
         VALUES newrec_
         RETURNING rowid INTO objid_;
      Employee_Translation_API.Insert_Basic_Data_Translation('WRKSCH', 'AbsenceAction',
         newrec_.company_id||'^'||newrec_.action_id,
         NULL, newrec_.action_description);
      objversion_ := to_char(newrec_.rowversion,'YYYYMMDDHH24MISS');
   EXCEPTION
      WHEN dup_val_on_index THEN
         DECLARE
            constraint_ VARCHAR2(4000) := Utility_SYS.Between_Str(Utility_SYS.Between_Str(sqlerrm, '(', ')'), '.', ')', 'FALSE');
         BEGIN
            IF (constraint_ = 'ABSENCE_ACTION_RK') THEN
               Error_SYS.Rowkey_Exist(lu_name_, newrec_.rowkey);
            ELSE
               Raise_Record_Exist___(newrec_);
            END IF;
         END;
   END Base;

BEGIN
   Base(objid_, objversion_, newrec_, attr_);
END Insert___;


PROCEDURE Prepare_New___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE )
   IS
      attr_    VARCHAR2(32000);
      indrec_  Indicator_Rec;
   BEGIN
      Prepare_Insert___(attr_);
      Unpack___(newrec_, indrec_, attr_);
   END Base;

BEGIN
   Base(newrec_);
END Prepare_New___;


PROCEDURE New___ (
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE )
   IS
      objid_         VARCHAR2(20);
      objversion_    VARCHAR2(100);
      attr_          VARCHAR2(32000);
      indrec_        Indicator_Rec;
      emptyrec_      absence_action_tab%ROWTYPE;
   BEGIN
      indrec_ := Get_Indicator_Rec___(emptyrec_, newrec_);
      Check_Insert___(newrec_, indrec_, attr_);
      Insert___(objid_, objversion_, newrec_, attr_);
   END Base;

BEGIN
   Base(newrec_);
END New___;


PROCEDURE Check_Update___ (
   oldrec_ IN     absence_action_tab%ROWTYPE,
   newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
   indrec_ IN OUT NOCOPY Indicator_Rec,
   attr_   IN OUT NOCOPY VARCHAR2 )
IS
   
   PROCEDURE Base (
      oldrec_ IN     absence_action_tab%ROWTYPE,
      newrec_ IN OUT NOCOPY absence_action_tab%ROWTYPE,
      indrec_ IN OUT NOCOPY Indicator_Rec,
      attr_   IN OUT NOCOPY VARCHAR2 )
   IS
   BEGIN
      Validate_SYS.Item_Update(lu_name_, 'COMPANY_ID', indrec_.company_id);
      Validate_SYS.Item_Update(lu_name_, 'ACTION_ID', indrec_.action_id);
      Check_Common___(oldrec_, newrec_, indrec_, attr_);
   END Base;

BEGIN
   Base(oldrec_, newrec_, indrec_, attr_);
END Check_Update___;


PROCEDURE Update___ (
   objid_      IN     VARCHAR2,
   oldrec_     IN     absence_action_tab%ROWTYPE,
   newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
   attr_       IN OUT NOCOPY VARCHAR2,
   objversion_ IN OUT NOCOPY VARCHAR2,
   by_keys_    IN     BOOLEAN DEFAULT FALSE )
IS
   
   PROCEDURE Base (
      objid_      IN     VARCHAR2,
      oldrec_     IN     absence_action_tab%ROWTYPE,
      newrec_     IN OUT NOCOPY absence_action_tab%ROWTYPE,
      attr_       IN OUT NOCOPY VARCHAR2,
      objversion_ IN OUT NOCOPY VARCHAR2,
      by_keys_    IN     BOOLEAN DEFAULT FALSE )
   IS
   BEGIN
      newrec_.rowversion := sysdate;
      IF by_keys_ THEN
         UPDATE absence_action_tab
            SET ROW = newrec_
            WHERE company_id = newrec_.company_id
            AND   action_id = newrec_.action_id;
      ELSE
         UPDATE absence_action_tab
            SET ROW = newrec_
            WHERE rowid = objid_;
      END IF;
         IF (NOT oldrec_.action_description = newrec_.action_description) THEN
            Employee_Translation_API.Update_Prog_Translation(module_, lu_name_,
               newrec_.company_id||'^'||newrec_.action_id,
               NULL, newrec_.action_description);
         END IF;
      objversion_ := to_char(newrec_.rowversion,'YYYYMMDDHH24MISS');
   EXCEPTION
      WHEN dup_val_on_index THEN
         DECLARE
            constraint_ VARCHAR2(4000) := Utility_SYS.Between_Str(Utility_SYS.Between_Str(sqlerrm, '(', ')'), '.', ')', 'FALSE');
         BEGIN
            IF (constraint_ = 'ABSENCE_ACTION_RK') THEN
               Error_SYS.Rowkey_Exist(Absence_Action_API.lu_name_, newrec_.rowkey);
            ELSE
               Raise_Record_Exist___(newrec_);
            END IF;
         END;
   END Base;

BEGIN
   Base(objid_, oldrec_, newrec_, attr_, objversion_, by_keys_);
END Update___;


PROCEDURE Modify___ (
   newrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
   lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE )
IS
   
   PROCEDURE Base (
      newrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
      lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE )
   IS
      objid_      VARCHAR2(20);
      objversion_ VARCHAR2(100);
      attr_       VARCHAR2(32000);
      indrec_     Indicator_rec;
      oldrec_     absence_action_tab%ROWTYPE;
   BEGIN
      IF (lock_mode_wait_) THEN
         oldrec_ := Lock_By_Keys___(newrec_.company_id, newrec_.action_id);
      ELSE
         oldrec_ := Lock_By_Keys_Nowait___(newrec_.company_id, newrec_.action_id);
      END IF;
      indrec_ := Get_Indicator_Rec___(oldrec_, newrec_);
      Check_Update___(oldrec_, newrec_, indrec_, attr_);
      Update___(objid_, oldrec_, newrec_, attr_, objversion_, TRUE);
   END Base;

BEGIN
   Base(newrec_, lock_mode_wait_);
END Modify___;


PROCEDURE Delete___ (
   objid_  IN VARCHAR2,
   remrec_ IN absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      objid_  IN VARCHAR2,
      remrec_ IN absence_action_tab%ROWTYPE )
   IS
      key_ VARCHAR2(2000);
   BEGIN
      key_ := remrec_.company_id||'^'||remrec_.action_id||'^';
      Reference_SYS.Do_Cascade_Delete(lu_name_, key_);
      IF (objid_ IS NOT NULL) THEN
         DELETE
            FROM  absence_action_tab
            WHERE rowid = objid_;
      ELSE
         DELETE
            FROM  absence_action_tab
            WHERE company_id = remrec_.company_id
            AND   action_id = remrec_.action_id;
      END IF;
      Employee_Translation_API.Remove_Basic_Data_Translation('WRKSCH', 'AbsenceAction',
         remrec_.company_id||'^'||remrec_.action_id);
   END Base;

BEGIN
   Base(objid_, remrec_);
END Delete___;


PROCEDURE Delete___ (
   remrec_ IN absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      remrec_ IN absence_action_tab%ROWTYPE )
   IS
   BEGIN
      Delete___(NULL, remrec_);
   END Base;

BEGIN
   Base(remrec_);
END Delete___;


PROCEDURE Remove___ (
   remrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
   lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE )
IS
   
   PROCEDURE Base (
      remrec_         IN OUT NOCOPY absence_action_tab%ROWTYPE,
      lock_mode_wait_ IN     BOOLEAN DEFAULT TRUE )
   IS
      oldrec_     absence_action_tab%ROWTYPE;
   BEGIN
      IF (lock_mode_wait_) THEN
         oldrec_ := Lock_By_Keys___(remrec_.company_id, remrec_.action_id);
      ELSE
         oldrec_ := Lock_By_Keys_Nowait___(remrec_.company_id, remrec_.action_id);
      END IF;
      Check_Delete___(oldrec_);
      Delete___(NULL, oldrec_);
   END Base;

BEGIN
   Base(remrec_, lock_mode_wait_);
END Remove___;

-----------------------------------------------------------------------------
-------------------- COMPANY SPECIFIC METHODS -------------------------------
-----------------------------------------------------------------------------

PROCEDURE Make_Company (
   attr_ IN VARCHAR2 )
IS
   
   PROCEDURE Base (
      attr_ IN VARCHAR2 )
   IS
      rec_ Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec;
   BEGIN
      rec_ := Enterp_Comp_Connect_V170_API.Get_Crecomp_Lu_Rec(module_, attr_);
      IF (rec_.make_company = 'EXPORT') THEN
         Export___(rec_);
      ELSIF (rec_.make_company = 'IMPORT') THEN
         IF (rec_.action = 'NEW') THEN
            Import___(rec_);
         ELSIF (rec_.action = 'DUPLICATE') THEN
            Copy___(rec_);
         END IF;
      END IF;
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'Make_Company');
   Base(attr_);
END Make_Company;


PROCEDURE Create_Company_Reg__ (
   execution_order_   IN OUT NOCOPY NUMBER,
   create_and_export_ IN     BOOLEAN  DEFAULT TRUE,
   active_            IN     BOOLEAN  DEFAULT TRUE,
   account_related_   IN     BOOLEAN  DEFAULT FALSE,
   standard_table_    IN     BOOLEAN  DEFAULT TRUE )
IS
   
   PROCEDURE Base (
      execution_order_   IN OUT NOCOPY NUMBER,
      create_and_export_ IN     BOOLEAN  DEFAULT TRUE,
      active_            IN     BOOLEAN  DEFAULT TRUE,
      account_related_   IN     BOOLEAN  DEFAULT FALSE,
      standard_table_    IN     BOOLEAN  DEFAULT TRUE )
   IS
   BEGIN
      Enterp_Comp_Connect_V170_API.Reg_Add_Component_Detail(
         module_, lu_name_, 'ABSENCE_ACTION_API',
         CASE create_and_export_ WHEN TRUE THEN 'TRUE' ELSE 'FALSE' END,
         execution_order_,
         CASE active_ WHEN TRUE THEN 'TRUE' ELSE 'FALSE' END,
         CASE account_related_ WHEN TRUE THEN 'TRUE' ELSE 'FALSE' END,
         'CCD_ABSENCEACTION', 'C1');
      Enterp_Comp_Connect_V170_API.Reg_Add_Table(
         module_,'ABSENCE_ACTION_TAB',
         CASE standard_table_ WHEN TRUE THEN 'TRUE' ELSE 'FALSE' END);
      Enterp_Comp_Connect_V170_API.Reg_Add_Table_Detail(
         module_,'ABSENCE_ACTION_TAB','COMPANY_ID','<COMPANY>');
      execution_order_ := execution_order_+1;
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'Create_Company_Reg__');
   Base(execution_order_, create_and_export_, active_, account_related_, standard_table_);
END Create_Company_Reg__;


PROCEDURE Create_Client_Mapping__ (
   client_window_ IN VARCHAR2 DEFAULT 'frmCreateCompanyTemDetail' )
IS
   
   PROCEDURE Base (
      client_window_ IN VARCHAR2 DEFAULT 'frmCreateCompanyTemDetail' )
   IS
      clmapprec_    Client_Mapping_API.Client_Mapping_Pub;
      clmappdetrec_ Client_Mapping_API.Client_Mapping_Detail_Pub;
   BEGIN
      clmapprec_.module := module_;
      clmapprec_.lu := lu_name_;
      clmapprec_.mapping_id := 'CCD_ABSENCEACTION';
      clmapprec_.client_window := client_window_;
      clmapprec_.rowversion := sysdate;
      Client_Mapping_API.Insert_Mapping(clmapprec_);
   
      clmappdetrec_.module := module_;
      clmappdetrec_.lu := lu_name_;
      clmappdetrec_.mapping_id :=  'CCD_ABSENCEACTION';
      clmappdetrec_.column_type := 'NORMAL';
      clmappdetrec_.translation_type := 'SRDPATH';
      clmappdetrec_.rowversion := sysdate;
   
      clmappdetrec_.column_id := 'C1' ;
      clmappdetrec_.translation_link := 'ABSENCE_ACTION.ACTION_ID';
      Client_Mapping_API.Insert_Mapping_Detail(clmappdetrec_);
   
      clmappdetrec_.column_id := 'C2' ;
      clmappdetrec_.translation_link := 'ABSENCE_ACTION.ACTION_DESCRIPTION';
      Client_Mapping_API.Insert_Mapping_Detail(clmappdetrec_);
   
      clmappdetrec_.column_id := 'C3' ;
      clmappdetrec_.translation_link := 'ABSENCE_ACTION.REMARKS';
      Client_Mapping_API.Insert_Mapping_Detail(clmappdetrec_);
   END Base;

BEGIN
   General_SYS.Init_Method(Absence_Action_API.lu_name_, 'Absence_Action_API', 'Create_Client_Mapping__');
   Base(client_window_);
END Create_Client_Mapping__;


PROCEDURE Export___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
IS
   
   PROCEDURE Base (
      crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
   IS
      pub_rec_ Enterp_Comp_Connect_V170_API.Tem_Public_Rec;
      i_       NUMBER := 1;
      CURSOR get_data IS
         SELECT *
         FROM  absence_action_tab
         WHERE company_id = crecomp_rec_.company;
   BEGIN
      FOR exprec_ IN get_data LOOP
         pub_rec_.template_id := crecomp_rec_.template_id;
         pub_rec_.component   := module_;
         pub_rec_.version     := crecomp_rec_.version;
         pub_rec_.lu          := lu_name_;
         pub_rec_.item_id     := i_;
         Export_Assign___(pub_rec_, crecomp_rec_, exprec_);
         Enterp_Comp_Connect_V170_API.Tem_Insert_Detail_Data(pub_rec_);
         i_ := i_ + 1;
      END LOOP;
   END Base;

BEGIN
   Base(crecomp_rec_);
END Export___;


PROCEDURE Export_Assign___ (
   pub_rec_     IN OUT NOCOPY Enterp_Comp_Connect_V170_API.Tem_Public_Rec,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   exprec_      IN     absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      pub_rec_     IN OUT NOCOPY Enterp_Comp_Connect_V170_API.Tem_Public_Rec,
      crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
      exprec_      IN     absence_action_tab%ROWTYPE )
   IS
   BEGIN
      pub_rec_.c1          := exprec_.action_id;
      pub_rec_.c2          := exprec_.action_description;
      pub_rec_.c3          := exprec_.remarks;
   END Base;

BEGIN
   Base(pub_rec_, crecomp_rec_, exprec_);
END Export_Assign___;


PROCEDURE Import___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
IS
   
   PROCEDURE Base (
      crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
   IS
      attr_        VARCHAR2(2000);
      objid_       VARCHAR2(2000);
      objversion_  VARCHAR2(2000);
      newrec_      absence_action_tab%ROWTYPE;
      empty_rec_   absence_action_tab%ROWTYPE;
      indrec_      Indicator_Rec;
      msg_         VARCHAR2(2000);
      i_           NUMBER := 0;
      run_crecomp_ BOOLEAN := FALSE;
      CURSOR get_data IS
         SELECT *
         FROM  Create_Company_Template_Pub src
         WHERE component   = module_
         AND   lu          = lu_name_
         AND   template_id = crecomp_rec_.template_id
         AND   version     = crecomp_rec_.version
         AND NOT EXISTS (SELECT 1
                         FROM  absence_action_tab
                         WHERE company_id = crecomp_rec_.company
                         AND   action_id = src.c1);
   BEGIN
      run_crecomp_ := Check_If_Do_Create_Company___(crecomp_rec_);
      IF (run_crecomp_) THEN
         FOR pub_rec_ IN get_data LOOP
            i_ := i_ + 1;
            --@ApproveTransactionStatement(2014-01-01,generated)
            SAVEPOINT make_company_insert;
            BEGIN
               newrec_ := empty_rec_;
               Import_Assign___(newrec_, crecomp_rec_, pub_rec_);
               Client_SYS.Clear_Attr(attr_);
               indrec_ := Get_Indicator_Rec___(newrec_);
               Check_Insert___(newrec_, indrec_, attr_);
               Insert___(objid_, objversion_, newrec_, attr_);
            EXCEPTION
               WHEN OTHERS THEN
                  msg_ := SQLERRM;
                  --@ApproveTransactionStatement(2014-01-01,generated)
                  ROLLBACK TO make_company_insert;
                  Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'Error', msg_);
            END;
         END LOOP;
         IF ( i_ = 0 ) THEN
            msg_ := Language_SYS.Translate_Constant(lu_name_, 'NODATAFOUND: No Data Found');
            Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully', msg_);
         ELSE
            IF msg_ IS NULL THEN
               Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully');
            ELSE
               Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedWithErrors');
            END IF;
         END IF;
      END IF;
      -- this statement is to add to the log that the Create company process for LUs is finished if
      -- run_crecomp_ are FALSE
      IF (NOT run_crecomp_) THEN
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully');
      END IF;
   EXCEPTION
      WHEN OTHERS THEN
         msg_ := SQLERRM;
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'Error', msg_);
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedWithErrors');
   END Base;

BEGIN
   Base(crecomp_rec_);
END Import___;


PROCEDURE Import_Assign___ (
   newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   pub_rec_     IN     Create_Company_Template_Pub%ROWTYPE )
IS
   
   PROCEDURE Base (
      newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
      crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
      pub_rec_     IN     Create_Company_Template_Pub%ROWTYPE )
   IS
   BEGIN
      newrec_.company_id                    := crecomp_rec_.company;
      newrec_.action_id                     := pub_rec_.c1;
      newrec_.action_description            := pub_rec_.c2;
      newrec_.remarks                       := pub_rec_.c3;
   END Base;

BEGIN
   Base(newrec_, crecomp_rec_, pub_rec_);
END Import_Assign___;


PROCEDURE Copy___ (
   crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
IS
   
   PROCEDURE Base (
      crecomp_rec_ IN Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec )
   IS
      attr_        VARCHAR2(2000);
      objid_       VARCHAR2(2000);
      objversion_  VARCHAR2(2000);
      newrec_      absence_action_tab%ROWTYPE;
      empty_rec_   absence_action_tab%ROWTYPE;
      indrec_      Indicator_Rec;
      msg_         VARCHAR2(2000);
      i_           NUMBER := 0;
      run_crecomp_ BOOLEAN := FALSE;
      CURSOR get_data IS
         SELECT *
         FROM  absence_action_tab src
         WHERE company_id = crecomp_rec_.old_company
         AND NOT EXISTS (SELECT 1
                         FROM  absence_action_tab
                         WHERE company_id = crecomp_rec_.company
                         AND   action_id = src.action_id);
   BEGIN
      run_crecomp_ := Check_If_Do_Create_Company___(crecomp_rec_);
      IF (run_crecomp_) THEN
         FOR oldrec_ IN get_data LOOP
            i_ := i_ + 1;
            --@ApproveTransactionStatement(2014-01-01,generated)
            SAVEPOINT make_company_insert;
            BEGIN
               newrec_ := empty_rec_;
               Copy_Assign___(newrec_, crecomp_rec_, oldrec_);
               Client_SYS.Clear_Attr(attr_);
               indrec_ := Get_Indicator_Rec___(newrec_);
               Check_Insert___(newrec_, indrec_, attr_);
               Insert___(objid_, objversion_, newrec_, attr_);
            EXCEPTION
               WHEN OTHERS THEN
                  msg_ := SQLERRM;
                  --@ApproveTransactionStatement(2014-01-01,generated)
                  ROLLBACK TO make_company_insert;
                  Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'Error', msg_);
            END;
         END LOOP;
         IF ( i_ = 0 ) THEN
            msg_ := Language_SYS.Translate_Constant(lu_name_, 'NODATAFOUND: No Data Found');
            Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully', msg_);
         ELSE
            IF msg_ IS NULL THEN
               Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully');
            ELSE
               Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedWithErrors');
            END IF;
         END IF;
      END IF;
      -- this statement is to add to the log that the Create company process for LUs is finished if
      -- run_crecomp_ are FALSE
      IF ( NOT run_crecomp_ ) THEN
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedSuccessfully');
      END IF;
   EXCEPTION
      WHEN OTHERS THEN
         msg_ := SQLERRM;
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'Error', msg_);
         Enterp_Comp_Connect_V170_API.Log_Logging(crecomp_rec_.company, module_, 'ABSENCE_ACTION_API', 'CreatedWithErrors');
   END Base;

BEGIN
   Base(crecomp_rec_);
END Copy___;


PROCEDURE Copy_Assign___ (
   newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
   crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
   oldrec_      IN     absence_action_tab%ROWTYPE )
IS
   
   PROCEDURE Base (
      newrec_      IN OUT NOCOPY absence_action_tab%ROWTYPE,
      crecomp_rec_ IN     Enterp_Comp_Connect_V170_API.Crecomp_Lu_Public_Rec,
      oldrec_      IN     absence_action_tab%ROWTYPE )
   IS
   BEGIN
      newrec_.company_id                    := crecomp_rec_.company;
      newrec_.action_id                     := oldrec_.action_id;
      newrec_.action_description            := oldrec_.action_description;
      newrec_.remarks                       := oldrec_.remarks;
   END Base;

BEGIN
   Base(newrec_, crecomp_rec_, oldrec_);
END Copy_Assign___;


FUNCTION Exist_Any___ (
   company_ IN VARCHAR2 ) RETURN BOOLEAN
IS
   
   FUNCTION Base (
      company_ IN VARCHAR2 ) RETURN BOOLEAN
   IS
      b_exist_  BOOLEAN  := TRUE;
      idum_     PLS_INTEGER;
      CURSOR exist_control IS
         SELECT 1
         FROM  absence_action_tab
         WHERE company_id = company_;
   BEGIN
      OPEN exist_control;
      FETCH exist_control INTO idum_;
      IF (exist_control%NOTFOUND) THEN
         b_exist_ := FALSE;
      END IF;
      CLOSE exist_control;
      RETURN b_exist_;
   END Base;

BEGIN
   RETURN Base(company_);
END Exist_Any___;


FUNCTION Check_If_Do_Create_Company___ (
   crecomp_rec_ IN ENTERP_COMP_CONNECT_V170_API.Crecomp_Lu_Public_Rec ) RETURN BOOLEAN
IS
   
   FUNCTION Base (
      crecomp_rec_ IN ENTERP_COMP_CONNECT_V170_API.Crecomp_Lu_Public_Rec ) RETURN BOOLEAN
   IS
      perform_update_ BOOLEAN;
      update_by_key_  BOOLEAN;
   BEGIN
      perform_update_ := FALSE;
      update_by_key_ := Enterp_Comp_Connect_V170_API.Use_Keys(module_, lu_name_, crecomp_rec_);
      IF (update_by_key_) THEN
         perform_update_ := TRUE;
      ELSE
         IF (NOT Exist_Any___(crecomp_rec_.company)) THEN
            perform_update_ := TRUE;
         END IF;
      END IF;
      RETURN perform_update_;
   END Base;

BEGIN
   RETURN Base(crecomp_rec_);
END Check_If_Do_Create_Company___;

-----------------------------------------------------------------------------
-------------------- LU SPECIFIC IMPLEMENTATION METHODS ---------------------
-----------------------------------------------------------------------------

PROCEDURE Check_Delete___ (
   remrec_ IN ABSENCE_ACTION_TAB%ROWTYPE )
IS
   
   PROCEDURE Base (
      remrec_ IN absence_action_tab%ROWTYPE )
   IS
      key_ VARCHAR2(2000);
   BEGIN
      key_ := remrec_.company_id||'^'||remrec_.action_id||'^';
      Reference_SYS.Check_Restricted_Delete(lu_name_, key_);
   END Base;

   PROCEDURE Core (
      remrec_ IN ABSENCE_ACTION_TAB%ROWTYPE )
   IS
   BEGIN
      Base(remrec_);
      Check_Action_Usage___(remrec_.company_id, remrec_.action_id);
   END Core;

BEGIN
   Core(remrec_);
END Check_Delete___;


PROCEDURE Check_Action_Usage___ (
   company_id_ IN VARCHAR2,
   action_id_ IN VARCHAR2)
IS
   
   PROCEDURE Core (
      company_id_ IN VARCHAR2,
      action_id_ IN VARCHAR2)
   IS
      CURSOR get_type_function IS
         SELECT function_id, absence_type_id, seq
         FROM type_division_definition_tab      
         WHERE company_id = company_id_
         AND function_id = 'T-ACTION'
         AND function_parameters like '_;'||action_id_||';%';
      CURSOR get_group_function IS
         SELECT function_id, group_id, seq
         FROM group_division_definition_tab      
         WHERE company_id = company_id_
         AND function_id = 'G-ACTION'
         AND function_parameters like '_;'||action_id_||';%';   
      function_id_ VARCHAR2(10);
      absence_type_ VARCHAR2(10);
      seq_ NUMBER;
      group_id_ VARCHAR2(40);
   BEGIN
      OPEN get_type_function;
      FETCH get_type_function INTO function_id_, absence_type_, seq_;
      IF get_type_function%FOUND THEN
         CLOSE get_type_function;
         Error_Sys.Appl_General(lu_name_, 'ACTIONUSED1: You cannot remove this action because is used in the absence type divide funtion definition. Absence type :P1, seq :P2, function :P3', absence_type_, seq_, function_id_);
      END IF;
      CLOSE get_type_function;
      OPEN get_group_function;
      FETCH get_group_function INTO function_id_, group_id_, seq_;
      IF get_group_function%FOUND THEN
         CLOSE get_group_function;
         Error_Sys.Appl_General(lu_name_, 'ACTIONUSED2: You cannot remove this action because is used in the absence group divide funtion definition. Absence group :P1, seq :P2, function :P3', group_id_, seq_, function_id_);
      END IF;
      CLOSE get_group_function;
   END Core;

BEGIN
   Core(company_id_, action_id_);
END Check_Action_Usage___;

-----------------------------------------------------------------------------
-------------------- FOUNDATION1 METHODS ------------------------------------
-----------------------------------------------------------------------------


--@IgnoreMissingSysinit
PROCEDURE Init
IS
   
   PROCEDURE Base
   IS
   BEGIN
      NULL;
   END Base;

BEGIN
   Base;
END Init;

BEGIN
   Init;
END Absence_Action_API;
